$j.fn.extend({
	loading2:function(){
		return this.each(function(){
			$j(this).html('<td colspan="9"><div class="loading_box"><div class="progress_bar"><img src="'+__ctxPath+'/images/icon/loadingBig.gif"/>loading...</div></div></td>');			
		});
	}
});

//显示操作按钮
function displayListButtons(status){

}


//创建管理员
function createAppAdmin(){
	var url = __ctxPath+"/system/appAdmin/ajaxPage.html?doAction=add&direct=false";
	showAppAdminForm(url);
}


//编辑客户
function editAppAdmin(appAdminId){
	var url = __ctxPath+"/system/appAdmin/ajaxPage.html?doAction=edit&direct=false&appAdminId="+appAdminId;
	showAppAdminForm(url);
}

//在本页以ajaxPage方式打开appAdminForm 
function showAppAdminForm(url,param){
	$j('#mainDiv').hide();
	$j('#formDiv').show().loading().load(url,param);
}

//删除多个
function deleteAppAdmins(){
	var paraData=$j("#appAdminListForm :input[name='multiIds']").serializeArray();
	if(paraData.length>0){
		var itemNames = fnGetSelectedItemNames();
		if(confirm( __FMT.common_message_confirmDeleteThis+ " " + itemNames+"?")){
			$j.post(__ctxPath + "/system/appAdmin/blank.html?doAction=multiDelete", paraData, deleteAppAdminsCallback,"json");
		}
	}else{
		alert(__FMT.appAdminList_selectAppAdmin);
	}
}
//删除后的回调函数
function deleteAppAdminsCallback(data){
	sysMsg(data.msg);
	refreshAppAdminList();
}
//保存多个
function multiSaveAppAdmins(){
	var paraData=$j("#appAdminListForm :input").serializeArray();
	$j.post(__ctxPath + "/system/appAdmin/blank.html?doAction=multiSave", paraData, multiSaveAppAdminsCallback,"json");
}
//保存多个后的回调函数
function multiSaveAppAdminsCallback(data){
	sysMsg(data.msg);
	refreshAppAdminList();
}

//保存重设的密码
function saveResetPassword(){
   	var form=$j("#passwordModel");
   	if(validateForm(form.get(0))){
   		var paramData=form.serializeArray();
   		function afterPost(data){
   			if (data.error == null) {
   				setTimeout("alert(__FMT.passwordReset_success)", 0);
					dlgresetPasswordDialog_close();
   			} else {
   				jAlert(data.error);
   			}
   		}
   		$j.post(__ctxPath+"/system/appAdmin/blank.html?doAction=saveResetPassword",paramData,afterPost,"json");
   	}else{
		alert(__vaMsg.notPass);
	}
}



//刷新列表
function refreshAppAdminList(){
	searchAppAdmins(false);
}
//分页
function fnOnGoToPage(){
	refreshAppAdminList();
}
//对已有结果进行排序,ascValue表示升序时对应的值,descValue表示降序时对应的值
function sortField(linkDOM,ascValue,descValue){
	var jThDOM = $j(linkDOM).parent('th');
	if(jThDOM.hasClass("order1")){
		$j('#storageOrderby').val(descValue);
	}else{
		$j('#storageOrderby').val(ascValue);
	}
	searchAppAdmins(false);
}


//搜索客户 isNew标示是否新的搜索,param标示是否自定义参数搜索
function searchAppAdmins(isNew,param){
	var postData;
	var url;
	if(isNew){
		if(null==param){
			if(validateSearchCriteria()){
				//有搜索结果搜索
			    postData = $j('#appAdminSearchCriteria :input').serializeArray();
			    url=__ctxPath+"/system/appAdmin/blank.html?doAction=search&btnSearch=1";
				$j("#appAdminResults").loading().load(url,postData);
		    }else{
		    	return;
		    }
		}else{
			//新的搜索。全部，上架等
			if(param.role  != undefined){
				$j('#appAdminResults #role').val(param.role);
			}
		    postData = $j('#appAdminResults :input').serializeArray();
		    url=__ctxPath+"/system/appAdmin/blank.html?doAction=search&btnSearch=1";
			$j("#appAdminResults").loading().load(url,postData);  
		}    
	}else{
		postData = $j('#appAdminResults :input').serializeArray();
		url=__ctxPath+"/system/appAdmin/blank.html?&doAction=search";
		$j("#appAdminResults").loading().load(url,postData);  
	} 
	
}



//验证函数
function validateSearchCriteria(){
	if(!validateForm($j('#appAdminSearchCriteria').get(0))){
    	return false;
   	}
   	return true;
}

//重设搜索条件
function resetSearchCriteria(){
	fnResetForm('appAdminSearchCriteria');
}



